package com.bianmaba.oauth2.sample.employee.controller;

import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;
import java.util.Map;

@RestController
public class EmployeeController {

    @RequestMapping({"/employee/{id}"})
    public Map<String, String> user(@PathVariable("id") String id) {
        Map<String, String> map = new LinkedHashMap<String, String>(3);
        map.put("name", "陈家彬");
        map.put("id", id);
        return map;
    }

    @RequestMapping({"/employee/get_by_id"})
    public Map<String, String> getById(@RequestParam MultiValueMap<String, String> params) {
        Map<String, String> map = new LinkedHashMap<String, String>(3);
        map.put("name", "陈家彬");
        map.put("id", params.getFirst("id"));
        return map;
    }
}
